package cn.tedu.flower.manage.content.dao.persist.repository.impl;

import cn.tedu.flower.manage.content.dao.persist.mapper.BannerMapper;
import cn.tedu.flower.manage.content.dao.persist.repository.IBannerRepository;
import cn.tedu.flower.manage.content.pojo.entity.Banner;
import cn.tedu.flower.manage.content.pojo.vo.BannerListItemVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 处理轮播图数据的存储库实现类
 *
 * @author java@tedu.cn
 * @version 1.0
 */
@Slf4j
@Repository
public class BannerRepositoryImpl implements IBannerRepository {

    @Autowired
    private BannerMapper bannerMapper;

    public BannerRepositoryImpl() {
        log.info("创建存储库对象：BannerRepositoryImpl");
    }

    @Override
    public int insert(Banner banner) {
        log.debug("开始执行【插入轮播图】的数据访问，参数：{}", banner);
        return bannerMapper.insert(banner);
    }

    @Override
    public int deleteById(Long id) {
        log.debug("开始执行【根据ID删除轮播图】的数据访问，参数：{}", id);
        return bannerMapper.deleteById(id);
    }

    @Override
    public int update(Banner banner) {
        log.debug("开始执行【更新轮播图】的数据访问，参数：{}", banner);
        return bannerMapper.updateById(banner);
    }

    @Override
    public List<BannerListItemVO> list() {
        log.debug("开始执行【查询轮播图列表】的数据访问，参数：无");
        return bannerMapper.list();
    }
}
